//
//  KABMineTicketTCell.m
//  kabu
//
//  Created by XiangDongMBP on 2017/2/16.
//  Copyright © 2017年 East. All rights reserved.
//

#import "KABMineTicketTCell.h"
#import "KABModel.h"
#import <YYWebImage.h>
#import "NSString+XDNSDate.h"
#import "NSDate+XDTimerFormatter.h"

@implementation KABMineTicketTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configViewWithExhOrderItem:(KABExhOrderListItem *)item {
    [self.posterImgView yy_setImageWithURL:[NSURL URLWithString:item.exhibition_cover_image_url]
                               placeholder:[KABDefaultVarModel sharedInstance].smallDefaultImg];
    
    self.titleLabel.text = item.exhibition_name;
    self.subTitleLabel.text = [NSString stringWithFormat:@"总价：￥%.2f", item.total_price / 100.0];
    self.timeLabel.text = item.create_time;
    self.endImgView.hidden = !item.is_expired;
}

- (void)configViewWithExhOrderDetail:(KABExhOrderDetail *)detail {
    [self.posterImgView yy_setImageWithURL:[NSURL URLWithString:detail.exhibition_cover_image_url]
                               placeholder:[KABDefaultVarModel sharedInstance].smallDefaultImg];
    
    self.titleLabel.text = detail.exhibition_name;
    
    self.subTitleLabel.text = [NSString stringWithFormat:@"电子票x%zd", detail.number];
    NSString *startTime = [[detail.exhibition_starttime xd_yyyyMMddHHmmssStrToDate] xd_yyyy_MM_ddHHmm];
    NSString *endTime = [[detail.exhibition_endtime xd_yyyyMMddHHmmssStrToDate] xd_yyyy_MM_ddHHmm];
    self.timeLabel.text = [NSString stringWithFormat:@"%@ - %@", startTime, endTime];
    
    self.endImgView.hidden = !detail.is_expired;
}

@end

@implementation KABMineTicketTCell (FollowExhibition)
- (void)configViewWithExhListItem:(KABExhListItem *)item {
    [self.posterImgView yy_setImageWithURL:[NSURL URLWithString:item.cover_image_url] placeholder:[KABDefaultVarModel sharedInstance].rectDefaultImg];
    
    self.titleLabel.text = item.name;
    
    NSString *startTime = [[item.start_time xd_yyyyMMddHHmmssStrToDate] xd_yyyyMMdd];
    NSString *endTime = [[item.end_time xd_yyyyMMddHHmmssStrToDate] xd_MMdd];
    self.subTitleLabel.text = [NSString stringWithFormat:@"%@-%@", startTime, endTime];
    self.timeLabel.text = [NSString stringWithFormat:@"%@ %@ %@ %@", item.province, item.city, item.district, item.address];
    self.endImgView.hidden = YES;
}

@end

